package housing.task1.generator;

import java.util.GregorianCalendar;
import java.util.Random;

public class AutoCompleter {

    public static String niceForm(String str) {
        String ret = str.toUpperCase().substring(0, 1) + str.toLowerCase().substring(1);
        return ret;
    }//String niceForm()

    public static GregorianCalendar generateDate() {
        int day_of_month = new Random().nextInt(28);
        return new GregorianCalendar(2010, 11, day_of_month);
    }

    public enum Address {
        EVERGREENTERAS, AVENUE1;

        static public int generateHouseNumber() {
            final int range = 10;
            int number = 1 + new Random().nextInt(range);    //1 added for numbers be greater than 0

            return number;
        }

        static public int generateFlatNumber() {
            final int range = 100;
            int number = 1 + new Random().nextInt(range);    //1 added for numbers be greater than 0

            return number;
        }

        static public String generateStreet() {
            final int randomIndex = new Random().nextInt(Address.values().length);
            final String street = Address.values()[randomIndex].toString();
            return niceForm(street);
        }

    }//enum ADDRESS


    public enum Names {
//        ALLA, ANNA, BEATA, CAROLINA, TASHA,
//        ANTON, BORIS, CYRIL, DIMA, PAVEL;
        HOMER, MARGE, BART, LISA, MAGGIE,
        MONTGOMERY, NED, MAUDE, WAYLON, MOE;

        public static String generate() {
            Random rand = new Random();
            String randomName = Names.values()[rand.nextInt(Names.values().length)].toString();
            return niceForm(randomName);
        }
    }//enum Names


    public enum Surnames {
        SIMPSON, FLANDERS, BURNS, SMITHERS, SZYSLAK;

        public static String generate() {
            Random rand = new Random();
            String randomSurname = Surnames.values()[rand.nextInt(Surnames.values().length)].toString();
            return niceForm(randomSurname);
        }
    }//enum Surnames


    /**
     * ENumeration of repair scales
     *
     * @author James Tymoshenko	 *
     */
    public enum WorkScale {
        S, M, L;             //Maybe should add OVERHAUL

        public static WorkScale generateWorkScale() {
            return WorkScale.values()[new Random().nextInt(WorkScale.values().length)];
        }//WorkScale generateWorkScale

        public static GregorianCalendar setWorkEndDate(final GregorianCalendar oldDate, WorkScale ws) {
            GregorianCalendar newDate = new GregorianCalendar();
            int incrementDay = 0;

            switch (ws) {
                case S:
                    incrementDay = 1;

                case M:
                    incrementDay = 3;

                case L:
                    incrementDay = 7;
            }//switch(ws)

            newDate.set(oldDate.get(GregorianCalendar.YEAR),
                    oldDate.get(GregorianCalendar.MONTH),
                    oldDate.get(GregorianCalendar.DAY_OF_MONTH)
                    + incrementDay);

            return newDate;
        }//GregorianCalendar setWorkEndDate(...);

    }//enumWorkScale


    /**
     * Enumeration of possible repair types
     *
     * @author James Tymoshenko	 *
     */
    public enum WorkType {
        ELECTRICAL, CARPENTRY, PLUMBING, CUSTOM;

        public static WorkType generateWorkType() {
            return WorkType.values()[new Random().nextInt(WorkType.values().length)];
        }
    }//enum WorkType

}//class AutoCompleter
